package com.sport.facilities.booking.system.htmlchecker;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.util.Log;

public class BasicChecker {
	private final String TAG = "TransferBookingResultChecker";
	private final String errPattern = "Error 500";

	public boolean hasError(String html) throws Exception {
		if (html == null) {
			Log.e(TAG, "Response is null exception.");
			throw new Exception("Response is null exception.");
		}
		Pattern pattern = Pattern.compile(errPattern);
		Matcher matcher = pattern.matcher(html);
		if (matcher.find()) {
			Log.e(TAG, "Error pattern found : "+ errPattern);
			throw new Exception("Error response from server:\n" + errPattern);
		} else {
			return false;
		}
	}
	/*
	 * TODO: Error Pattern 1 : 01-11 16:33:22.955:
	 * D/InquireBookingChecker(1045): bookingMadeHtml:Error 500:
	 * java.lang.NullPointerException
	 */

	/*
	 * TODO: Error Pattern 2 : <body bgcolor='#FFFFFF'
	 * onLoad="ermsg('The session is NOT available')">
	 */

	/*
	 * TODO: Error Pattern3 : 01-23 14:02:28.690: I/System.out(8261): <p>The
	 * server is busy, please try again later. </p>
	 */

}
